package com.atguigu.gulimall.ssoclient.controller;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.sql.DataSourceDefinition;
import javax.servlet.http.HttpSession;
import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

@Controller
public class HelloController {


    @GetMapping("/hello")
    public String hello(){

        return "hello";
    }

    @GetMapping("/employees")
    public String employee(Model model, HttpSession session){

        Object loginUser = session.getAttribute("loginUser");

        if(loginUser==null){
            //没登录，跳转到登录服务器

        }

        List<Employee> employees = new ArrayList<>();


        employees.add(new Employee("ZS",13));
        employees.add(new Employee("LS",12));

        model.addAttribute("emps",employees);

        return "list";
    }

    @Data
    @AllArgsConstructor
    class Employee{

        private String name;
        private int age;
    }
}
